package javase.jmx.examples.mxbean;

import java.lang.management.ManagementFactory;

import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;

public class MXAgent {

	public static void main(String[] args) throws 
					MalformedObjectNameException,
					NullPointerException,
					InstanceAlreadyExistsException,
					MBeanRegistrationException,
					NotCompliantMBeanException,
					InterruptedException {
		
		MBeanServer server = ManagementFactory.getPlatformMBeanServer();
		ObjectName name = new ObjectName("javase.jmx.examples.mxbean:type=CacheManager");
		CacheManager mxbean = new CacheManager();
		server.registerMBean(mxbean, name);

		System.out.println("Waiting forever...");
		Thread.sleep(Long.MAX_VALUE);
	}

}
